﻿using System;
using System.Collections.Generic;
using System.Linq;
using Interfaces.Validation;
using ServiceInfrastructure.Models.Exceptions;

namespace Framework.Exceptions.ServiceExceptions
{
    public class ValidationException : Exception
    {
        public IEnumerable<BusinessFaultDetails> Details { get; set; }
        
        public ValidationException(string message, IValidationResult result)
            : base(message)
        {
            Details = result.BrokenRules.Select(x => new BusinessFaultDetails(x.RuleId, x.Message, x.Tag));
        }

        
    }
}
